package com.woniuxy.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.woniuxy.entity.DisRequirements;
import com.woniuxy.entity.Procurement;

@Mapper
public interface DisRequirementsMapper {
	//查询分配单
	@Select("select * from t_distribution_requirements")
	public List<DisRequirements> findRequirements();
	
	//查询一条分配单
	@Select("select * from t_distribution_requirements where orderno=#{orderno}")
	public DisRequirements finddisRequirementByOrderno(String orderno);
	
	//插入一条数据
	@Insert("insert into t_distribution_requirements values(default,#{orderno},#{supplier},#{department},"
			+ "#{weight},#{num},#{wname},#{rname},#{time},#{status},#{line},#{category},#{storehome},#{quality})")
	public int insertDisprocurement(DisRequirements dis);
	
	//编辑分配单
	@Update("update t_distribution_requirements set category=#{category},storehome=#{storehome},quality=#{quality},time=#{time},status=#{status} where orderno=#{orderno}")
	public int updatedistributionByOrderno(DisRequirements dis);
	
	//删除分配单
	@Delete("delete from t_distribution_requirements where orderno=#{orderno}")
	public int delDisByOrderno(String orderno);
	
	//提交采购
	@Insert("insert into t_procurement values(default,#{orderno},#{supplier},#{prodepartment},"
			+ "#{weight},#{num},#{name},#{time},#{status},#{category},#{line},#{storehouse},#{quality},#{formtype})")
	public int insertToProcurement(Procurement procurement);
	
	//提交后修改状态
	@Update("update t_distribution_requirements set status=#{status} where orderno=#{orderno}")
	public int changeStatus(DisRequirements disRequirements);
}
